package com.tanhua.server.service;

import com.tanhua.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

@Service
public class UserService {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${tanhua.sso.url}")
    private String restUrl;

    public User queryUserByToken(String token) {
        try {
            String url = restUrl+"/user/"+token;
            User user = restTemplate.getForObject(url, User.class);
            return user;
        } catch (RestClientException e) {
            e.printStackTrace();
        }
        return null;
    }
}
